package tictactoe;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

import tictactoe.*;
import tictactoe.gameplay.*;
import tictactoe.screens.*;
import tictactoe.types.*;

/**
 *
 * @author Ryan Falls
 */
public class MenuItemMouseAdapter extends MouseAdapter
{
	//Static variables
	protected static final int borderSize = 8;
	protected static final Border hoverBorder = new LineBorder(Color.yellow, borderSize);
	protected static final Border emptyBorder = new EmptyBorder(borderSize, borderSize, borderSize, borderSize);
	//Private variables
	private Screens targetScreen;

	public MenuItemMouseAdapter()
	{
		this.targetScreen = null;
	}

	public MenuItemMouseAdapter(Screens screen)
	{
		this.targetScreen = screen;
	}

	@Override public void mouseEntered(MouseEvent e)
	{
		JLabel cell = (JLabel)(e.getComponent());
		cell.setBorder(hoverBorder);
	}

	@Override public void mouseExited(MouseEvent e)
	{
		JLabel cell = (JLabel)(e.getComponent());
		cell.setBorder(emptyBorder);
	}

	@Override public void mouseClicked(MouseEvent e)
	{
		if (targetScreen != null)
		{
			Component c = e.getComponent();
			MainMenuScreen m = (MainMenuScreen)(c.getParent());
			m.ChangeScreen(targetScreen);
		}
	}
}
